package cc.iotkit.manager.controller.miniApp;

import cc.iotkit.manager.dto.vo.deviceinfo.DeviceInfoVo;
import cc.iotkit.manager.dto.vo.miniApp.*;
import cc.iotkit.manager.service.IDeviceManagerService;
import cc.iotkit.model.product.Product;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = {"用户端设备管理"})
@Slf4j
@RestController
@RequestMapping("/miniApp")
public class MiniAppDeviceController {

    @Autowired
    private IDeviceManagerService IDeviceManagerService;


    @ApiOperation(value = "设备信息", notes = "设备信息", httpMethod = "POST")
    @PostMapping("/deviceInfo")
    public MiniAppDeviceInfoRspVo deviceInfo(@RequestBody MiniAppDeviceInfoReqVo reqVo) {
        //MiniAppDeviceInfoReqVo reqVo = pageRequest.getData();
        return IDeviceManagerService.getDeviceInfo(reqVo.getDeviceNo());
    }


    @ApiOperation(value = "附近机柜", notes = "附近机柜", httpMethod = "POST")
    @PostMapping("/nearCabinets")
    public List<DeviceInfoVo> nearCabinets(@RequestBody MiniAppNearCabinetsReqVo reqVo) {
        //MiniAppNearCabinetsReqVo reqVo = request.getData();
        return IDeviceManagerService.getNearByDevices(reqVo.getLatitude(),reqVo.getLongitude());
    }


    @ApiOperation(value = "商品类型列表", notes = "商品类型列表", httpMethod = "POST")
    @PostMapping("/productTypes")
    public List<Product> productTypes(@RequestBody MiniAppDeviceInfoReqVo reqVo) {
        //MiniAppDeviceInfoReqVo reqVo = request.getData();
        return IDeviceManagerService.productTypes(reqVo.getDeviceNo());
    }

    @ApiOperation(value = "商品列表", notes = "商品列表", httpMethod = "POST")
    @PostMapping("/products")
    public List<MiniAppProductDetailRspVo> products(@RequestBody MiniAppProductReqVo reqVo) {
        //MiniAppProductReqVo reqVo = request.getData();
        return IDeviceManagerService.products(reqVo);
    }


//    @ApiOperation(value = "商品详情", notes = "商品列表", httpMethod = "POST")
//    @PostMapping("/products")
//    public List<MiniAppProductDetailRspVo> products(@RequestBody MiniAppProductDetailReqVo reqVo) {
//        //MiniAppProductReqVo reqVo = request.getData();
//        return IDeviceManagerService.products(reqVo);
//    }






}
